package com.example.rest_client_projet;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import com.tyczj.extendedcalendarview.CalendarProvider;
import com.tyczj.extendedcalendarview.Event;
import com.tyczj.extendedcalendarview.ExtendedCalendarView;

import java.util.Calendar;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;

/**
 * Created by richard on 19/03/14.
 */
public class planningDay extends Activity{


    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.calendarday);
        Intent intent = getIntent();
        String message = intent.getStringExtra("id");
        Log.e("DEBUG #", message);

        ExtendedCalendarView calendar = (ExtendedCalendarView)findViewById(R.id.calendar);

        ContentValues values = new ContentValues();
        values.put(CalendarProvider.COLOR, Event.COLOR_GREEN);
        values.put(CalendarProvider.DESCRIPTION, "Some Description");
        values.put(CalendarProvider.LOCATION, "Some location");
        values.put(CalendarProvider.EVENT, "Work");


        Calendar cal = Calendar.getInstance();

        TimeZone tz = TimeZone.getDefault();

        cal.set(2014, 03,03, 12, 30);
      //  values.put(CalendarProvider.START, cal.getTimeInMillis());
        int DayJulian =android.text.format.Time.getJulianDay(cal.getTimeInMillis(), TimeUnit.MILLISECONDS.toSeconds(tz.getOffset(cal.getTimeInMillis())));

       // values.put(CalendarProvider.START_DAY, DayJulian);

        cal.set(2014, 03,03, 20, 20);
        int endDayJulian =android.text.format.Time.getJulianDay(cal.getTimeInMillis(), TimeUnit.MILLISECONDS.toSeconds(tz.getOffset(cal.getTimeInMillis())));
        values.put(CalendarProvider.START, cal.getTimeInMillis());
        values.put(CalendarProvider.START_DAY, endDayJulian);

        values.put(CalendarProvider.END, cal.getTimeInMillis());
        values.put(CalendarProvider.END_DAY,endDayJulian );



        Uri uri = getContentResolver().insert(CalendarProvider.CONTENT_URI, values);

    }
}